package com.studerb.view.headers;

import javax.swing.JScrollPane;
import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.AbstractApplicationContext;

import com.studerb.model.NewsGroup;

public class HeadersPane extends JScrollPane implements ApplicationContextAware {
    private static Logger logger = Logger.getLogger(HeadersPane.class);
    private NewsGroup newsGroup;
    private HeadersTableModel tableModel;
    private AbstractApplicationContext appContext;
    private HeadersTable headersTable;
    

    public HeadersPane(NewsGroup newsGroup) {
        super();
        logger.debug("Constructor: " + newsGroup.getGroupName());
        this.newsGroup = newsGroup;
    }
    
    public void init(){
        this.tableModel = (HeadersTableModel)appContext.getBean("headersTableModel", new Object[] {newsGroup});
        this.headersTable = (HeadersTable)appContext.getBean("headersTable", new Object[] {this.tableModel});
        this.setViewportView(headersTable);
    }

    @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.appContext = (AbstractApplicationContext)applicationContext;
    }
}


